package com.jingxi.portal.service;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.jingxi.common.pojo.JingXiResult;
import com.jingxi.common.pojo.SearchResult;
import com.jingxi.common.util.HttpClientUtil;

@Service
public class SeachServiceImpl implements SearchService {

	@Override
	public SearchResult search(String url, String q, Integer page,Integer rows) {
		Map<String, String> getParam = new HashMap<String, String>();
		getParam.put("q", q);
		getParam.put("page", page+"");
		getParam.put("rows", rows+"");
		String result = HttpClientUtil.doGet(url, getParam);
		JingXiResult jingXiResult = JingXiResult.formatToPojo(result, SearchResult.class);
		System.out.println("JR" + result);
		SearchResult searchResult = (SearchResult) jingXiResult.getData();
		return searchResult;
	}

}
